﻿using QFramework;
using System;

namespace HKTools
{
    /// <summary>
    /// 完成指定任务的指令
    /// </summary>
    public class CMD_STS_CompleteAppointTask : AbstractCommand
    {
        /// <summary>
        /// 任务队列类型
        /// </summary>
        STS_TaskQueueType taskQueueType;

        /// <summary>
        /// 要完成的任务类型
        /// </summary>
        Enum taskType;

        /// <summary>
        /// 延时完成时间
        /// </summary>
        float delayTime;

        /// <summary>
        /// 构造函数，完成指定任务指令
        /// </summary>
        public CMD_STS_CompleteAppointTask(STS_TaskQueueType taskQueueType, Enum taskType, float delayTime = 0)
        {
            this.taskQueueType = taskQueueType;
            this.taskType = taskType;

            if (delayTime <= 0)
                this.delayTime = 0;
            else
                this.delayTime = delayTime;
        }

        /// <summary>
        /// 执行指令，完成指定任务。
        /// </summary>
        protected override void OnExecute()
        {
            // 调用任务系统，完成指定任务
            this.GetSystem<IHK_SimpleTaskSystem>().CompleteAppointTask(taskQueueType, taskType, delayTime);
        }
    }
}